package com.tsingsoft.tolerant;

import com.tsingsoft.common.dao.DBAccess;
import com.tsingsoft.common.dao.DaoImpl;
import com.tsingsoft.util.UtilDateTime;

public class ForecastValidate implements IValidate{
	
	private String windfarm_id;
	
	public ForecastValidate(String strWf)
	{
		windfarm_id = strWf;
	}
	
	private boolean isAllNull(Double[] arrValue)
	{
		if(arrValue == null || arrValue.length <= 0)
		{
			return false;
		}
		
		boolean isNull = true;
		for(Double dValue : arrValue)
		{
			if(dValue != null)
			{
				isNull = false;
				
				break;
			}
		}
		
		return isNull;
	}

	@Override
	public boolean isDataExistInDB() {
		DaoImpl dao = (DaoImpl)DaoImpl.getInstance(Integer.valueOf(DBAccess.FORECASTNUMBER));
		
		String strToday = UtilDateTime.nowDateStr2();
		Double[] dValue = dao.getFcValue(DBAccess.FORECASTNUMBER, 
				UtilDateTime.addDays(strToday, 1), strToday + "00", Long.getLong(windfarm_id));

		return isAllNull(dValue);
	}
}
